from apps.public.extentions import validation, parse_json_form
from apps.picture.business.picturenumdistinguish import PictureNumDisBusiness
from flask import jsonify, current_app, jsonify

from library.api.tBlueprint import tblueprint

bpname = 'num'
num = tblueprint(bpname, __name__)


@num.route('/', methods=['POST'])
def picture_num():
    """识别图片数字
    @api {POST} v1/picture/num/ 图片识别
    :return:
    """
    # token = PictureNumDisBusiness.get_ai_token()
    # result = PictureNumDisBusiness.handle_picture(token)
    result = [{'location': {'width': 117, 'top': 35, 'left': 44, 'height': 33}, 'words': '中国联通'},
              {'location': {'width': 82, 'top': 34, 'left': 648, 'height': 31}, 'words': '令'},
              {'location': {'width': 179, 'top': 362, 'left': 323, 'height': 49}, 'words': '输入密码'},
              {'location': {'width': 47, 'top': 696, 'left': 619, 'height': 67}, 'words': '3'},
              {'location': {'width': 50, 'top': 697, 'left': 388, 'height': 266}, 'words': '285'},
              {'location': {'width': 67, 'top': 768, 'left': 381, 'height': 26}, 'words': ' ABC'},
              {'location': {'width': 63, 'top': 768, 'left': 611, 'height': 26}, 'words': ' DEF'},
              {'location': {'width': 51, 'top': 898, 'left': 158, 'height': 62}, 'words': '4'},
              {'location': {'width': 50, 'top': 897, 'left': 619, 'height': 67}, 'words': '6'},
              {'location': {'width': 63, 'top': 969, 'left': 152, 'height': 25}, 'words': ' GHI'},
              {'location': {'width': 62, 'top': 969, 'left': 382, 'height': 25}, 'words': ' JKL'},
              {'location': {'width': 73, 'top': 969, 'left': 606, 'height': 26}, 'words': ' MNO'},
              {'location': {'width': 44, 'top': 1096, 'left': 160, 'height': 68}, 'words': '7'},
              {'location': {'width': 49, 'top': 1097, 'left': 616, 'height': 66}, 'words': '9'},
              {'location': {'width': 88, 'top': 1167, 'left': 139, 'height': 27}, 'words': ' PQRS'},
              {'location': {'width': 51, 'top': 1096, 'left': 387, 'height': 282}, 'words': '80'},
              {'location': {'width': 69, 'top': 1168, 'left': 379, 'height': 26}, 'words': ' TUV'},
              {'location': {'width': 95, 'top': 1168, 'left': 595, 'height': 26}, 'words': ' WXYZ'},
              {'location': {'width': 132, 'top': 1654, 'left': 118, 'height': 38}, 'words': '紧急情况'},
              {'location': {'width': 65, 'top': 1655, 'left': 609, 'height': 36}, 'words': '取消'}]
    num = PictureNumDisBusiness.filter_num(result)
    return jsonify({'status': 0, 'msg': num})
